<template>
  <div class="manager-container">
    <div class="left-container">
      <div class="left-header">
        <div class="icon-container">
          <img src="@/assets/ico.png"/>
        </div>
        <div class="text-container">零食管理</div>
      </div>
      <!--右侧栏项-->
      <div class="left-item-container" @click="onClickLeftItem(0,'商品管理')">
        <div class="left-icon-container">
          <img src="@/assets/menu.png">
        </div>
        <div class="left-text-container">
          商品管理
        </div>
      </div>
      <!--右侧栏项-->
      <!--右侧栏项-->
      <div class="left-item-container" @click="onClickLeftItem(1,'订单管理')">
        <div class="left-icon-container">
          <img src="@/assets/menu.png">
        </div>
        <div class="left-text-container">
          订单管理
        </div>
      </div>
      <!--右侧栏项-->
      <!--右侧栏项-->
      <div class="left-item-container" @click="onClickLeftItem(2,'图库管理')">
        <div class="left-icon-container">
          <img src="@/assets/menu.png">
        </div>
        <div class="left-text-container">
          图库管理
        </div>
      </div>
      <div class="left-item-list" v-if="index===2">
        <div class="list-item" @click="onClickLeftSubItem('图片列表')"> 
          <div>图片列表</div>
        </div>
        <div class="list-item" @click="onClickLeftSubItem('图片上传')">
          <div>图片上传</div>
        </div>
      </div>
      <!--右侧栏项-->
      <!--右侧栏项-->
      <div class="left-item-container" @click="onClickLeftItem(3,'主页管理')">
        <div class="left-icon-container">
          <img src="@/assets/menu.png">
        </div>
        <div class="left-text-container">
          主页管理
        </div>
      </div>
      <!--右侧栏项-->
      <!--右侧栏项-->
      <div class="left-item-container" @click="onClickLeftItem(4,'数据统计')">
        <div class="left-icon-container">
          <img src="@/assets/menu.png">
        </div>
        <div class="left-text-container">
          数据统计
        </div>
      </div>
      <!--右侧栏项-->
    </div>
    <div class="right-container">
      <!--右侧标题栏-->
        <div class="right-header">
          <div class="icon-container">
            <img src="@/assets/content.png" />
          </div>
          <div class="text-container">
            {{mainTitle}}
          </div>
        </div>
        <!--右侧标题栏-->
        <div class="show-container">
          <router-view></router-view>
        </div>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return {
      rightTitle:'首页',
      subTitile:'',
      index:-1
    }
  },
  computed:{
    mainTitle(){
      return this.rightTitle+' > '+this.subTitile
    }
  },
  methods:{
    onClickLeftItem(index,title){
      this.index = index
      this.rightTitle = title
      this.subTitile = ''
      switch(index){
        case 0:{
          if(this.$router.currentRoute.fullPath!='/manager/goods')
          {this.$router.push('/manager/goods')
          this.onClickLeftSubItem('商品管理')}
          break;
        }
        case 1:{
          if(this.$router.currentRoute.fullPath!='/manager/records'){
          this.$router.push('/manager/records')
          this.onClickLeftSubItem('查看订单')}
          break;
        }
        case 2:{
          if(this.$router.currentRoute.fullPath!='/manager/tuku'){
          this.$router.push('/manager/tuku')
          this.subTitile = '图片列表'}
          break;
        }
        case 3:{
          if(this.$router.currentRoute.fullPath!='/manager/mainShow/swipper'){
          this.$router.push('/manager/mainShow')
          this.subTitile = '主页管理'}
          break;
        }
        case 4:{
          if(this.$router.currentRoute.fullPath!='/manager/board'){
          this.$router.push('/manager/board')
          this.subTitile = '数据统计'}
          break;
        }
      }
    },
    onClickLeftSubItem(subTitile){
      if(this.subTitile===subTitile)
        return
      this.subTitile = subTitile
      if(subTitile==='图片列表')
      {
        this.$router.push('/manager/tuku')
      }else if(subTitile==='图片上传'){
        this.$router.push('/manager/imageUpload')
      }
    }
  },
  mounted(){
    this.onClickLeftItem(0,'商品管理')
    
  }
}
</script>

<style lang="less">

  .manager-container{
    display: flex;
    height: 100%;
    justify-content: stretch;
    .left-container{
      // flex-grow: 1;
      width: 15%;
      height: 100%;
      background-color: #585858;
      .left-item-list{
        width: 100%;
        .list-item{
          width: 100%;
          height: 30px;
          text-align: center;
          line-height: 30px;
          background-color: #6b6b6b;
          div{
            text-decoration: none;
            color: #dddddd;
            font-size: 13px;
            width: 100%;
            cursor: pointer;
            margin-left: -15px;
            display: block;
          }
        }
        .list-item:hover{
          background-color: #525252;
        }
      }
      .left-item-container:hover{
        background-color: #454444;
        cursor: pointer;
      }
      .left-item-container{
        height: 60px;
        display: flex;
        .left-icon-container{
          display: flex;
          align-items: center;
          margin-left: 10px;
          img{
            width: 30px;
          }
        }
        .left-text-container{
          display: flex;
          align-items: center;
          margin-left: 10px;
          color: #ffffff;
        }
      }
      .left-header{
        display: flex;
        justify-content: stretch;
        align-items: center;
        height: 60px;
        background-color: rgb(44, 43, 43);
        padding: 10px;
        box-sizing: border-box;
        .icon-container{
          box-sizing: border-box;
          display: flex;
          align-items: center;
          img{
            width: 40px;
          }
          flex: 1;
        }
        .text-container{
          font-weight: 500;
          color: aliceblue;
          font-size: 15px;
          width: 80px;
          box-sizing: border-box;
          margin: 0;
          flex: 2;
        }
      }
    }
    .right-container{
      width: 85%;
      height: 100%;
      background-color: #e2e2e4;
      display: flex;
      flex-direction: column;
      .show-container{
        position: relative;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex:1
      }
      .right-header{
        height: 60px;
        width: 100%;
        background-color: #ffffff;
        display: flex;
        justify-content: left;
        .icon-container{
          box-sizing: border-box;
          display: flex;
          align-items: center;
          height: 60px;
          margin-left: 20px;
          img{
            width: 30px;
          }
        }
        .text-container{
          margin-left: 20px;
          line-height: 60px;
          color: #979696;
        }
      }
    }  
  }
</style>